package com.example.tys.dex;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Process;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {
    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        return new MyBinder();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i("----", "server onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onCreate() {
        super.onCreate();

        String a = getApplication().getString(R.string.app_name);
        Log.i("-----", "MyService:" + getApplication());
        Log.i("-----", "MyService:" + getApplicationContext());
        Log.i("-----", "MyService:" + getApplicationInfo().className + " : " + a +
                " 包名:" + getPackageName());
        Toast.makeText(this, ""+getPackageName(),Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("tag", "server onDestroy");
    }

    class MyBinder extends Binder {

        public int getPid() {
            return Process.myPid();
        }

        public int getTid() {
            return Process.myTid();
        }

        public int getUid() {
            return Process.myUid();
        }
    }

}
